#-------------------------------------------------------------------------------
#   flipflop.tcl
#   ============
#   Flip through textures using a flipflop object.
#-------------------------------------------------------------------------------
sel ('/usr/scene')
execfile ('licht.py')
animmesh=new ('n3dnode','animmesh')
sel ('animmesh')
animmesh.sxyz(0.3,0.3,0.3)
rotz=new ('nipol','rotz')
sel ('rotz')
rotz.connect('rz')
rotz.addkey1f(0,0)
rotz.addkey1f(10,360)
sel ('..')
rotx=new ('nipol','rotx')
sel ('rotx')
rotx.connect('rx')
rotx.addkey1f(0,0)
rotx.addkey1f(20,360)
sel ('..')
mesh=new ('nmeshipol','mesh')
sel ('mesh')
mesh1=new ('nmeshnode','mesh1')
mesh1.setfilename("../meshes/torus1.n3d")
mesh1.setreadonly(1)
mesh2=new ('nmeshnode','mesh2')
mesh2.setfilename("../meshes/torus2.n3d")
mesh2.setreadonly(1)
mesh3=new ('nmeshnode','mesh3')
mesh3.setfilename("../meshes/torus3.n3d")
mesh3.setreadonly(1)
mesh4=new ('nmeshnode','mesh4')
mesh4.setfilename("../meshes/torus4.n3d")
mesh4.setreadonly(1)
mesh5=new ('nmeshnode','mesh5')
mesh5.setfilename("../meshes/torus5.n3d")
mesh5.setreadonly(1)
mesh.beginkeys (7)
mesh.setkey (0,0,'mesh1')
mesh.setkey (1,3,'mesh2')
mesh.setkey (2,6,'mesh3')
mesh.setkey (3,9,'mesh5')
mesh.setkey (4,12,'mesh4')
mesh.setkey (5,15,'mesh5')
mesh.setkey (6,18,'mesh1')
mesh.endkeys ()
mesh.setupdatecoord (1)
mesh.setupdatenorm (1)
mesh.setupdatecolor (0)
mesh.setupdateuv0 (1)
mesh.setupdateuv1 (0)
mesh.setupdateuv2 (0)
mesh.setupdateuv3 (0)
sel ('..')
sn=new ('nshadernode','sn')
sel ('sn')
sn.setnumstages(2)
sn.setcolorop(0,"mul tex prev" )
sn.setcolorop(1,"ipol tex prev const.a" )
sn.begintunit(0)
sn.setaddress('wrap','wrap')
sn.setminmagfilter('linear','linear')
sn.settexcoordsrc('uv0')
sn.setenabletransform(1)
sn.endtunit()
sn.sxyz0(2,2,2)
sn.begintunit(1)
sn.setaddress('wrap','wrap')
sn.setminmagfilter('linear','linear')
sn.settexcoordsrc('spheremap')
sn.setenabletransform(1)
sn.endtunit()
sn.setconst0(0.2,0.2,0.2,0.2)
sn.setlightenable(1)
sn.setdiffuse(0.5,0.5,0.5,1.0)
sn.setemissive(1,0,0,0)
sn.setambient(0,0,0,0)
sn.setalphaenable(0)
sel ('..')
flip=new ('nflipflop','flip')
sel ('flip')
tex0=new ('ntexarraynode','tex0')
sel ('tex0')
tex0.settexture(0,'../bmp/marble.bmp','none')
tex0.settexture(1,'../bmp/autobahn.bmp','none')
sel ('..')
tex1=new ('ntexarraynode','tex1')
sel ('tex1')
tex1.settexture(0,'../bmp/brick.bmp','none')
tex1.settexture(1,'../bmp/autobahn.bmp','none')
sel ('..')
tex2=new ('ntexarraynode','tex2')
sel ('tex2')
tex2.settexture(0,'../bmp/funky.bmp','none')
tex2.settexture(1,'../bmp/autobahn.bmp','none')
sel ('..')
flip.addkey(0.0,'tex0')
flip.addkey(5.0,'tex1')
flip.addkey(10.0,'tex2')
flip.addkey(15.0,'tex0')
sel ('..')
sel ('..')
